<!--
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-20 15:47:13
 * @LastEditTime: 2022-11-02 14:18:10
-->
<template>
  <div class="link-order">
    <div class="flex flex-horizontal-between">
      <p class="title">关联订单</p>
    </div>
    <div class="table-contractor">
      <Table :columns="columns" :data="data" border></Table>
    </div>
  </div>

</template>
<script>
  export default {
    props: ['detailMsg', 'buildingId', 'subscriptionId'],
    data() {
      return {
        isView: this.$route.meta.isbuild == 'nobuildpage' ? true : false, // 是否是汇总数据跳转
        columns: [
        {
          title: '序号',
          type: 'index',
        },
        {
          title: '订单编号',
          key: 'orderCode',
        },
        {
          title: '订单类型',
          key: 'orderType',
          render: (h, params) => {
            return h(
              'div',
              this.$formatter.switchName('orderType', params.row.orderType)
            )
          },
        },
        {
          title: '创建时间',
          key: 'createTime',
        },
        {
          title: '操作',
          render: (h, params) => {
            return h('div', [
              h(
                'a',
                {
                  on: {
                    click: (e) => {
                      e.stopPropagation()
                      this.linkOrderParams(params.row)
                    },
                  },
                },
                params.row.orderType != 'HANDOVER' ? '查看' : '' // 交房单不支持查看
              ),
            ])
          },
        }],
        data: [],
      }
    },
    mounted() {
      this.data = this.detailMsg.relationOrderVOS
    },
    methods: {
      linkOrderParams(item) {
        // 认购: 'RG',
        // 退购: 'UR',
        // 签约: 'QY',
        // 退签: 'UQ',
        // 认购调整: 'TR',
        // 签约调整: 'TQ',
        let orderParams = {}
        let type = item.orderCode.slice(0, 2)
        switch (type) {
          case 'RG':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: ''
            }
          case 'UR':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: ''
            }
            break
          case 'QY':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: this.subscriptionId,
            }
            break
          case 'UQ':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: '',
            }
            break
          case 'TR':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              orderType: '认购'
            }
            break
          case 'TQ':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.orderId, // 业务id
              orderType: '签约'
            }
            break
          default:
            break
        }
        this.linkOrderFun(orderParams)
      },
    },
  }
</script>
<style lang="scss" scoped>
  .link-order {
    margin-top: 40px;

    .table-contractor {
      margin-top: 20px;
    }
  }
</style>